#include<stdio.h>
#include<unistd.h>
#include<errno.h>
#include<string.h>
#include<sys/types.h>
#include<sys/stat.h>
#include<fcntl.h>

//int main()
//{
//  fprintf(stdout,"hello vic\n");
//  const char* msg="hello world\n";
//  write(1,msg,strlen(msg));//1号文件描述符表示 stdout
//  fork();
//  return 0;
//}
#define bit "bit.txt"
void write_c()
{
  FILE* fp=fopen(bit,"w");
  const char* msg="linux so easy!\n";
  fprintf(fp,"%s",msg);
  fclose(fp);

}
void read_c()
{
  FILE* fp=fopen(bit,"r");
  char line[100];
  fgets(line,sizeof(line),fp);
  fclose(fp);
  printf("%s\n",line);

}
void write_sys()
{
  umask(0);
  const char* msg="i like linux!\n";
  int fd=open(bit,O_CREAT|O_WRONLY|O_TRUNC,0666);
  write(fd,msg,strlen(msg));
  close(fd);
}
void read_sys()
{
  umask(0);
  char line[100];
  int fd=open(bit,O_RDONLY,0666);
  read(fd,line,sizeof(line));
  printf("%s",line);
  close(fd);
  
}
int main()
{
 // write_c();
 // read_c();
 
  write_sys();
  read_sys();
 


  return 0;
}
